<?php

class loginmodule {
	function name() { return exponent_lang_loadKey('modules/loginmodule/class.php','module_name'); }
	function author() { return 'ABSoft.vn'; } 
	function description() { return exponent_lang_loadKey('modules/loginmodule/class.php','module_description'); }
	
	function hasContent() { return false; }
	function hasSources() { return false; }
	function hasViews()   { return true; }
	
	function supportsWorkflow() { return false; }
	
	function permissions($internal = '') {
		return array();
	}
	
	function deleteIn($loc) {
		// Do nothing, no content
	}
	
	function copyContent($from_loc,$to_loc) {
		// Do nothing, no content
	}

	function show($view,$loc=null,$title='') {
		global $user,$browser;
		$template = new template('loginmodule',$view,$loc);
		$template->assign('title',$title);
        $template->assign('mobile',$browser->isMobile()?1:0);
		if (exponent_sessions_loggedIn()) {
		  // 8/29/2009: Immanuel192 change this code ; when you are logged in
		  // just redirect to Administrator Quicklink
		  if ($view == "Login Button")
		  {
			administrationmodule::show("Quick Links",$loc,$title);
		  return;   
		  }
		  else
		  {
            $user;
            global $db;
            $file = $db->selectObject('file', 'id='.$user->file_id);
            $user->avatar = "/".$file->directory.'/'.$file->filename;              
			$template->assign('loggedin',1);  
			$template->assign('user',$user);
		  }
			/*global $db;
			$template->assign('loggedin',1);
			$template->assign('user',$user);
			// Generate display name as username if the first and last name fields are blank.
			$display_name = $user->firstname . ' ' .$user->lastname;
			if (trim($display_name) == '') {
				$display_name = $user->username;
			}
			$template->assign('displayname',$display_name);
			// Need to check for groups and whatnot
			if ($db->countObjects('groupmembership','member_id='.$user->id.' AND is_admin=1')) {
				$template->assign('is_group_admin',1);
			} else {
				$template->assign('is_group_admin',0);
			}*/
		} else {
			$template->assign('loggedin',0);
		}
        
        // permission to show Profile Management for approved person
        $template->assign('can_upload_profile',exponent_permissions_check(array("upload"),exponent_core_makeLocation("profilemodule","_syscore","")));
        
		$template->assign('moduletitle',$title);
		$template->assign('temp',rand(1,15690));
		$template->output($view);
	}
	
	function spiderContent($item = null) {
		// Do nothing, no content
		return false;
	}
	
}
?>
